//package com.zmn.plat.dubbo.impl.product;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.annotation.Resource;
//
//import org.apache.dubbo.config.annotation.Service;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.Cacheable;
//import org.springframework.cglib.beans.BeanCopier;
//
//import com.alibaba.fastjson.JSON;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.number.NumberUtil;
//import com.zmn.common.utils.string.StringUtil;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.common.dictionary.PlatErrorCodeDict;
//import com.zmn.plat.common.dto.product.BaseCodeMapDIO;
//import com.zmn.plat.common.dto.product.BaseCodeMapDRO;
//import com.zmn.plat.dubbo.interfaces.product.BaseCodeMapListRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.product.BaseCodeMap;
//import com.zmn.plat.model.entity.product.BaseCodeMapQuery;
//import com.zmn.plat.services.interfaces.product.BaseCodeMapService;
//import com.zmn.plat.utils.bean.BeanCopyUtils;
//
//import lombok.extern.slf4j.Slf4j;
//
///**
// * @author tanghongjun
// * @version v1.0 @类说明：
// * @since 2018/10/16 11:30
// */
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//@CacheConfig(cacheNames = "redis1h")
//@Slf4j
//public class BaseCodeMapListRemoteServiceImpl implements BaseCodeMapListRemoteService {
//
//    @Resource
//    private BaseCodeMapService baseCodeMapService;
//
//    @Override
//    @Cacheable(value = "redis1h", key = "'dubbo:list:basecode:' + #p0")
//    @ReadOnlyConnection
//    public ResponseDTO<BaseCodeMapDRO> getById(Integer mapId) {
//        log.info("getById param is:mapId={}", mapId);
//
//        BaseCodeMap baseCodeMap = baseCodeMapService.findByKey(mapId);
//        BaseCodeMapDRO baseCodeMapDRO = new BaseCodeMapDRO();
//        BeanCopyUtils.copyProperties(baseCodeMap, baseCodeMapDRO);
//
//        return ResponseDTO.success(baseCodeMapDRO, "OK");
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<BaseCodeMapDRO>> listByDIO(BaseCodeMapDIO baseCodeMapDIO) {
//        log.info("listByDIO param is:baseCodeMapDIO={}", baseCodeMapDIO);
//        BaseCodeMapQuery query = new BaseCodeMapQuery();
//        BeanCopyUtils.copyProperties(baseCodeMapDIO, query);
//
//        query.setCacheKey(JSON.toJSONString(baseCodeMapDIO).replace("\"", "").replace("{", "").replace("}", "").replace(",", ":"));
//        List<BaseCodeMap> baseCodeMapList = baseCodeMapService.listByQueryOfCache(query);
//
//        return this.listToDRO(baseCodeMapList);
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<Boolean> checkByOneTypeIdAndTwoTypeIdAndNameAndPlat(Integer oneTypeId, Integer twoTypeId, String name, Integer plat) {
//        log.info("checkByOneTypeIdAndTwoTypeIdAndNameAndPlat param is:oneTypeId={},twoTypeId={},name={},plat={}", oneTypeId, twoTypeId, name, plat);
//
//        if (NumberUtil.isNullOrZero(oneTypeId) || NumberUtil.isNullOrZero(plat)) {
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PANAM_NULL);
//        }
//
//        BaseCodeMapQuery query = new BaseCodeMapQuery();
//        query.setOneTypeId(oneTypeId);
//        query.setPlat(plat);
//
//        if (!NumberUtil.isNullOrZero(twoTypeId)) {
//            query.setTwoTypeId(twoTypeId);
//        }
//
//        if (StringUtil.isNotBlank(name)) {
//            query.setName(name);
//        }
//
//        int count = baseCodeMapService.countByQuery(query);
//        if (count >= 1) {
//            return ResponseDTO.success(true);
//        } else {
//            return ResponseDTO.success(false);
//        }
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<BaseCodeMapDRO>> listByOneTypeIdAndTwoTypeIdAndNameAndPlat(Integer oneTypeId, Integer twoTypeId, String name, Integer plat) {
//        log.info("listByOneTypeIdAndTwoTypeIdAndNameAndPlat param is:oneTypeId={},twoTypeId={},name={},plat={}", oneTypeId, twoTypeId, name, plat);
//
//        if (NumberUtil.isNullOrZero(oneTypeId)) {
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PANAM_NULL);
//        }
//
//        BaseCodeMapQuery query = new BaseCodeMapQuery();
//        query.setOneTypeId(oneTypeId);
//
//        if (!NumberUtil.isNullOrZero(plat)) {
//            query.setPlat(plat);
//        }
//
//        if (StringUtil.isNotBlank(name)) {
//            query.setName(name);
//        }
//
//        if (!NumberUtil.isNullOrZero(twoTypeId)) {
//            query.setTwoTypeId(twoTypeId);
//        }
//
//        return this.listToDRO(baseCodeMapService.listByQuery(query));
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<BaseCodeMapDRO>> listByOneTypeIdAndTwoTypeIdAndThreeTypeIdAndNameAndPlat(Integer oneTypeId, Integer twoTypeId, Integer threeTypeId, String name, Integer plat) {
//        log.info("listByOneTypeIdAndTwoTypeIdAndThreeTypeIdAndNameAndPlat param is:oneTypeId={},twoTypeId={},name={},plat={},threeTypeId={}", oneTypeId, twoTypeId, name, plat, threeTypeId);
//
//        if (NumberUtil.isNullOrZero(oneTypeId)) {
//            return ResponseDTO.fromErrorCodeTable(PlatErrorCodeDict.ERROR_CODE_PANAM_NULL);
//        }
//
//        BaseCodeMapQuery query = new BaseCodeMapQuery();
//        query.setOneTypeId(oneTypeId);
//        query.setPlat(plat);
//
//        if (StringUtil.isNotBlank(name)) {
//            query.setName(name);
//        }
//
//        if (!NumberUtil.isNullOrZero(twoTypeId)) {
//            query.setTwoTypeId(twoTypeId);
//        }
//
//        if (!NumberUtil.isNullOrZero(threeTypeId)) {
//            query.setThreeTypeId(threeTypeId);
//        }
//
//        return this.listToDRO(baseCodeMapService.listByQuery(query));
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<BaseCodeMapDRO>> listAll() {
//        List<BaseCodeMap> baseCodeMapList = baseCodeMapService.listAll();
//
//        return this.listToDRO(baseCodeMapList);
//    }
//
//    private ResponseDTO<List<BaseCodeMapDRO>> listToDRO(List<BaseCodeMap> baseCodeMapList) {
//        List<BaseCodeMapDRO> items = new ArrayList<>();
//        BaseCodeMapDRO baseCodeMapDRO;
//        BeanCopier copier = BeanCopier.create(BaseCodeMap.class, BaseCodeMapDRO.class, false);
//        for (int i = 0; i < baseCodeMapList.size(); i++) {
//            baseCodeMapDRO = new BaseCodeMapDRO();
//            copier.copy(baseCodeMapList.get(i), baseCodeMapDRO, null);
//            items.add(baseCodeMapDRO);
//        }
//
//        return ResponseDTO.success(items);
//    }
//
//}
